package shuishijie.suishijie.view;

import android.app.Activity;
import android.widget.EditText;
import android.widget.Toast;

import shuishijie.suishijie.R;
import shuishijie.suishijie.util.AppUtil;


/**
 * Created by zhangrl on 2017/8/30.
 */
public class PasswordInputPopup extends BasePopup<Double> {

    EditText editText;

    public PasswordInputPopup(Activity activity, Double data) {
        super(activity, R.layout.popup_input, data);
    }

    @Override
    protected void initView(Double data) {
        editText = rootView.findViewById(R.id.password);
        setText(R.id.price, AppUtil.getMoneyStr(data));
        addOnClickView(R.id.close);
        addOnClickView(R.id.btn_ok);
        setOnClickListener(view -> {
            if (view.getId() == R.id.close) {
                dismiss();
                // none
            } else if (editText.getText().length() <= 0) {
                Toast.makeText(activity, "请输入密码", Toast.LENGTH_LONG).show();
            } else if (listener != null) {
                listener.OnInput(editText.getText().toString());
            }
        });
    }

    public void setListener(OnTextInputListener listener) {
        this.listener = listener;
    }

    OnTextInputListener listener;

    public static interface OnTextInputListener {
        public void OnInput(String text);
    }
}
